package cn.gson.bing.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.gson.bing.bean.User;
import cn.gson.bing.dao.UserDao;
import cn.gson.bing.mapper.UserMapper;

@Controller
public class AppController {
	
	@Autowired
	UserDao userDao;
	@Autowired
	UserMapper userMapper;
	
	@RequestMapping("/")
	public String ss(Model model){
		model.addAttribute("hello", "Hello Spring Boot");
		User us = new User();
		us.setUserName("user"+Math.random());
		us.setPassword("123456");
		userDao.save(us);
		List<User> users =  userMapper.findAll();
		model.addAttribute("users", users);
		return "index";
	}
}
